using UnityEngine;
using System.Collections;

public class CreateCube : MonoBehaviour {

	// Use this for initialization
	void Start () {
	
	}
	
	// Update is called once per frame	
	void Update () {
		
	}
	
	public static void createRandom(){
		GameObject cube = GameObject.CreatePrimitive(PrimitiveType.Cube);
		
		int direction = Random.Range(0,5);
		int px = 0;
		int py = 20;
		int pz = 0;
		switch(direction){
			case 0://left
				px = Random.Range(0,50);
				pz = Random.Range(50,540);
				break;
			case 1://up
				px = Random.Range(50,960);
				pz = Random.Range(490,540);
				break;
			case 2://right
				px = Random.Range(910,960);
				pz = Random.Range(0,510);
				break;
			case 3://down
				px = Random.Range(0,910);
				pz = Random.Range(0,50);
				break;
		}
		cube.transform.position = new Vector3(px,py,pz);
		cube.transform.localScale = new Vector3(40, 40, 40);
		cube.renderer.material.color = 
			new Color(Random.Range(0,255)/255f,
				Random.Range(0,255)/255f,
				Random.Range(0,255)/255f,
				1.0f);		
		BoxCollider bc = cube.GetComponent("BoxCollider") as BoxCollider;
		bc.isTrigger = true;
		
		cube.AddComponent("Rigidbody");		
		Rigidbody rigi = cube.GetComponent("Rigidbody") as  Rigidbody;
		rigi.isKinematic = true;
		
		
		cube.AddComponent("CubeMove");
	}	
}
